<?php
class members {
    function set_page($new_page) {
        $this->pageid = $new_page;
        return $this->pageid;
    }

    function set_id($new_id) {
        $this->id = $new_id;
        return $this->id;
    }

    function get_latestMembers() {
        $connect = new mysqli(DB_HOST,DB_USER,DB_PASS,DB_NAME);
        $query = $connect->query("SELECT id, username, joined, avatar FROM ".$prefix."users ORDER BY joined DESC LIMIT 5");

        while($row = $query->fetch_object()) {

            if(empty($row->avatar)) {
                $userfolder = "default";
                $avatar = "nopicture.gif";
            }
            else {
                $userfolder = strtolower($row->username);
                $avatar = strtolower($row->avatar);
            }

            $joined = date('m-d',strtotime($row->joined));

            $this->memberlist[] = array(
                "userfolder" => $userfolder,
                "avatar" => $avatar,
                "id" => $row->id,
                "username" => $row->username,
                "joined" => $joined
            );
        }
        return $this->memberlist;
        $query->close();
        $connect->close();
    }
}
?>
